package com.ysd.lis.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.ysd.common.Result;
import com.ysd.lis.entity.WkTrainingPlan;
import com.ysd.lis.entity.WkTrainingUser;
import com.ysd.lis.mapper.WkTrainingUserMapper;
import com.ysd.lis.request.TrainingUserUpdateSignParam;
import com.ysd.lis.service.WkTrainingUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 培训计划人员表 服务实现类
 * </p>
 *
 * @author LiuQi
 * @since 2024-03-20
 */
@Service
public class WkTrainingUserServiceImpl extends ServiceImpl<WkTrainingUserMapper, WkTrainingUser> implements WkTrainingUserService {

    @Autowired
    WkTrainingUserMapper wkTrainingUserMapper;

    @Override
    public Result updateSignStatusByUserId(TrainingUserUpdateSignParam trainingUserUpdateSignParam) {
        LambdaUpdateWrapper<WkTrainingUser> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        lambdaUpdateWrapper.set(WkTrainingUser::getIsSign, trainingUserUpdateSignParam.getValue())
                .eq(WkTrainingUser::getUserId, trainingUserUpdateSignParam.getUserId())
                .eq(WkTrainingUser::getTrainingId, trainingUserUpdateSignParam.getTrainingId());
        int update = wkTrainingUserMapper.update(null, lambdaUpdateWrapper);
        if (update > 0) {
            return Result.succ(1, "编辑成功！", update);
        } else {
            return Result.fail("编辑失败");
        }
    }



}
